package com.chinaisafe.user.vo.request;

import com.chinaisafe.base.common.vo.request.PageReqVo;
import com.chinaisafe.base.common.validated.UpdateGroup;
import jakarta.validation.constraints.NotNull;
import com.chinaisafe.user.entity.SysUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
 * SysUserReqVO
 * Description：用户请求值对象
 *
 * @author xuefu.shu
 * @date  2024-07-15 09:33:58
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysUserReqVO", description = "用户请求值对象")
public class SysUserReqVO extends PageReqVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    @NotNull(groups = UpdateGroup.class, message = "主键id不能为空" )
    private Long id;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "账号_id")
    private Long sysAccountId;

    @Schema(description = "用户扩展信息_id")
    private Long sysUserExtendId;

    @Schema(description = "账号")
    private String account;

    @Schema(description = "昵称")
    private String nickName;

    @Schema(description = "行政部门id")
    private Long administrationDeptId;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "邮箱")
    private String mail;

    @Schema(description = "身份证")
    private String identityCard;

    @Schema(description = "帐号状态（0正常 1停用）")
    private Short status;

    @Schema(description = "头像")
    private String avatar;

    @Schema(description = "签名")
    private String signature;

    @Schema(description = "用户类别 1, 超级管理员 2, 平台管理员 3, 企业管理员  4, 企业用户")
    private Integer userType;

    @Schema(description = "人脸")
    private String face;

    @Schema(description = "IMEI")
    private String imei;


    /**
     * 将请求值对象装换为实体
     * @return SysUser
     * @author xuefu.shu
     * @date 2024-07-15 09:33:58
     */
    public SysUser convertToEntity() {
        SysUser entity = new SysUser();
        entity.setId(this.id);
        entity.setVersion(this.version);
        // 给实体对应的字段赋值 可根据实际业务删减
        entity.setSysAccountId(this.sysAccountId);
        entity.setSysUserExtendId(this.sysUserExtendId);
        entity.setAccount(this.account);
        entity.setNickName(this.nickName);
        entity.setAdministrationDeptId(this.administrationDeptId);
        entity.setMobile(this.mobile);
        entity.setMail(this.mail);
        entity.setIdentityCard(this.identityCard);
        entity.setStatus(this.status);
        entity.setAvatar(this.avatar);
        entity.setSignature(this.signature);
        entity.setUserType(this.userType);
        entity.setFace(this.face);
        entity.setImei(this.imei);
        return entity;
    }
}
